package com.elitel.frame.base.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.elitel.frame.base.service.BaseRepaddonsService;
import com.elitel.frame.main.dao.BaseRepaddonsMapper;
import com.elitel.frame.main.dao.ext.ExtBaseRepaddonsMapper;
import com.elitel.frame.main.dao.ext.ExtBaseRepconfigMapper;
import com.elitel.frame.main.entity.BaseRepaddons;
import com.elitel.frame.main.entity.BaseRepconfig;

/**
 * 
 * <pre>@ProjectName：frame-base-service    
 * @ClassName：BaseRepaddonsServiceImpl    
 * @Description: TODO(报表附属信息实现类)    
 * @author：FanWenquan  
 * @date：2017年8月24日 上午9:10:33       
 * @version </pre>
 */
@Service
public class BaseRepaddonsServiceImpl implements BaseRepaddonsService{
	
	@Autowired
	private BaseRepaddonsMapper baseRepaddonsMapper;
	@Autowired
	private ExtBaseRepconfigMapper extBaseRepconfigMapper;
	@Autowired
	private ExtBaseRepaddonsMapper extBaseRepaddonsMapper;

	@Override
	public BaseRepaddons selectBaseRepaddonsByKey(String raguid) {
		BaseRepaddons selectByPrimaryKey = baseRepaddonsMapper.selectByPrimaryKey(raguid);
		return selectByPrimaryKey;
	}
	
	@Override
	public List<BaseRepaddons> getRepaddonsCheck(String rguid, String tempId) {
		List<BaseRepconfig> selectRepConfigByRguid = extBaseRepconfigMapper.selectRepConfigByRguid(rguid);
		List<String> list = new ArrayList<String>();
		for (BaseRepconfig br : selectRepConfigByRguid) {
			list.add(br.getRaguid());
		}
		List<BaseRepaddons> baserea = extBaseRepaddonsMapper.getRepaddonsCheck(list, tempId);
		return baserea;
	}

	@Override
	public List<BaseRepaddons> queryRepaddonsByTempId(String tempId) {
		List<BaseRepaddons> list = extBaseRepaddonsMapper.queryRepaddonsByTempId(tempId);
		return list;
	}

	@Override
	public int insertRepaddons(BaseRepaddons baseRepaddons) {
		int size = baseRepaddonsMapper.insertSelective(baseRepaddons);
		return size;
	}

	@Override
	public int updateRepaddons(BaseRepaddons baseRepaddons) {
		int size = baseRepaddonsMapper.updateByPrimaryKeySelective(baseRepaddons);
		return size;
	}

	@Override
	public int deleteRepaddonsByKey(String guid) {
		int size = baseRepaddonsMapper.deleteByPrimaryKey(guid);
		return size;
	}

	@Override
	public BaseRepaddons queryRepaddonsByKey(String guid) {
		BaseRepaddons addons = baseRepaddonsMapper.selectByPrimaryKey(guid);
		return addons;
	}
}
